package com.wangnan.currentactivity.extract.datafunction;

import android.util.Log;

import com.wangnan.currentactivity.BaseApplication;
import com.wangnan.currentactivity.Dao.BillList;
import com.wangnan.currentactivity.extract.IData;
import com.wangnan.currentactivity.extract.RecycleDetailsExtract;
import com.wangnan.currentactivity.util.ActivityUtil;
import com.wangnan.currentactivity.util.CustomToast;

//微信账单
public class 	WeChatBillingI    extends IData {
	RecycleDetailsExtract a = new RecycleDetailsExtract();
	public WeChatBillingI(String billtime, String billAmount, String billRmarkse, String billStatus, String billName, String type) {
		super(billtime, billAmount, billRmarkse, billStatus, billName, type);
	}

	@Override
	public void Data() {
		for (int j = 0; j < BaseApplication.userDetailsList.size(); j++) {        //微信的账单详情在最后一个字
			Log.e("zzh", "进入微信第几个:" + j + "哈哈长度" + BaseApplication.userDetailsList.size());
			if (BaseApplication.userDetailsList.get(j).getName().equals("支付时间")) {
				billtime = BaseApplication.userDetailsList.get(j + 1).getName(); //微信订单时间
			}
			if (BaseApplication.userDetailsList.get(j).getName().equals("转账时间")) {
				billtime = BaseApplication.userDetailsList.get(j + 1).getName(); //微信订单时间
			}
			if (BaseApplication.userDetailsList.get(j).getName().equals("退款时间")) {
				billtime = BaseApplication.userDetailsList.get(j + 1).getName(); //微信订单时间
			}
			if (BaseApplication.userDetailsList.get(j).getName().equals("收款时间")) {
				billtime = BaseApplication.userDetailsList.get(j + 1).getName(); //微信订单时间
			}
			if (BaseApplication.userDetailsList.get(j).getName().equals("到账时间")) {
				billtime = BaseApplication.userDetailsList.get(j + 1).getName(); //微信订单时间
			}
			if (BaseApplication.userDetailsList.size() > 3) {
				billAmount = BaseApplication.userDetailsList.get(2).getName(); //微信实付金额(元)
				billName = BaseApplication.userDetailsList.get(1).getName(); //微信名称
			}
			if (BaseApplication.userDetailsList.get(j).getName().equals("支付方式")) {
				billRmarkse = BaseApplication.userDetailsList.get(j + 1).getName(); //微信交易类型
			}
			if (BaseApplication.userDetailsList.get(j).getName().equals("退款方式")) {
				billRmarkse = BaseApplication.userDetailsList.get(j + 1).getName(); //微信交易类型
			}
			if (BaseApplication.userDetailsList.get(j).getName().equals("当前状态")) {
				billStatus = BaseApplication.userDetailsList.get(j + 1).getName(); //微信当前状态
			}
			if (BaseApplication.userDetailsList.get(j).getName().equals("退款状态")) {
				billStatus = BaseApplication.userDetailsList.get(j + 1).getName(); //微信当前状态
			}
			if (j == BaseApplication.userDetailsList.size() - 1) {
				String textshow = "交易时间 = " + billtime + "\n" +
						"金额 = " + billAmount + "\n" +
						"备注 = " + billRmarkse + "\n" +
						"状态 = " + billStatus + "\n" +
						"名称 = " + billName + "\n";
				Log.e("zzh", "进入微信进行添加数据库" + "BillList{" +
						", billtime='" + billtime + '\'' +
						", billAmount='" + billAmount + '\'' +
						", billRmarkse='" + billRmarkse + '\'' +
						", billStatus='" + billStatus + '\'' +
						", billName='" + billName + '\'' +
						'}');
				CustomToast.showToast(BaseApplication.getGlobalApplication(), textshow);
				BillList billList = new BillList(ActivityUtil.getUUIDTOLongNew(), type, billtime, billAmount, billRmarkse, billStatus, billName);
				//                      BaseApplication.billListDao.insertBillLists(billList);
				a.writeToTheDatabaseRoom(billList);
			}
		}
	}
}